from django.db import models
from django.contrib.auth.models import User


# Create your models here.


class MyUser(models.Model):
    """用户"""
    username = models.CharField('用户名', max_length=16)
    password = models.CharField('密码', max_length=64)

    def __str__(self):  # 添加完 在admin中下拉框不再显示为数据集（objects对象）
        return self.username

    class Meta:
        db_table = 'bk_user'


class Title(models.Model):
    """标题"""
    title = models.CharField('标题', max_length=16)
    date_add = models.DateTimeField(auto_now_add=True)

    owner = models.ForeignKey(MyUser, on_delete=models.CASCADE)

    def __str__(self):  # 添加完 在admin中下拉框不再显示为数据集（objects对象）
        return self.title

    class Meta:
        db_table = 'bk_title'
        # verbose_name = '标题'  # 负数名 在admin管理后台显示
        verbose_name_plural = '标题'  # 单数名 在admin管理后台显示

class Content(models.Model):
    """内容"""
    text = models.TextField('内容')
    date_add = models.DateTimeField(auto_now_add=True)
    title = models.ForeignKey(Title, on_delete=models.CASCADE)

    class Meta:
        db_table = 'bk_content'
        # verbose_name = '内容'
        verbose_name_plural = '内容'